#{extends 'main.html' /}
#{set title:'Tommy Blog !' /}

#{if frontPost}
    <div class="post">
        <h2 class="post-title">
            <a href="@{Home.show(frontPost.id)}">${frontPost.title}</a>
        </h2>
        <div class="post-metadata">
            <span class="post-author">作者: ${frontPost.author.fullname}</span>
            <span class="post-date">时间: ${frontPost.postedAt.format('MMM dd')}</span>
            <span class="post-comments">
                &nbsp;|&nbsp; 
                ${frontPost.comments.size() ?: 'no'} 
                回复:${frontPost.comments.size().pluralize()}
                #{if frontPost.comments}
                    , 最后回复: ${frontPost.comments[0].author}
                #{/if}
            </span>
        </div>
        <div class="post-content">
            ${frontPost.content.nl2br()}
        </div>
    </div>
    
    #{if olderPosts.size() > 1}
        <div class="older-posts">    
            <h3>所有文章: </h3>
        
            #{list items:olderPosts, as:'oldPost'}
                <div class="post">
                    <h2 class="post-title">
                        <a href="@{Home.show(oldPost.id)}">${oldPost.title}</a>
                    </h2>
                    <div class="post-metadata">
                        <span class="post-author">
                            作者: ${oldPost.author.fullname}
                        </span>
                        <span class="post-date">
                            ${oldPost.postedAt.format('dd MMM yy')}
                        </span>
                        <div class="post-comments">
                            ${oldPost.comments.size() ?: '0'} 
                            回复 
                            #{if oldPost.comments}
                                 最新回复: ${oldPost.comments[0].author}
                            #{/if}
                        </div>
                    </div>
                </div>
            #{/list}
        </div>
        
    #{/if}
    
#{/if}
 
#{else}
    <div class="empty">
        当前博客为空!
    </div>
#{/else}